<?php

namespace CtyunOss\struct;

use CtyunOss\cors\ArrayObject;

/**
 * Class ListAllMyBucketsResult
 * @package CtyunOss\object
 *
 * @author  Violet_Ice紫冰 <violetice@aliyun.com>
 * @create  2020-06-26 16:01:28
 */
class ListAllMyBucketsResult extends ArrayObject
{
    /** @var Owner 所有者 */
    public $Owner;

    /** @var Bucket[] 容器列表 */
    public $Buckets;

    public function __construct(array $data = [])
    {
        parent::__construct();
        $this->Owner = new Owner($data['Owner']);

        if (!empty($data['Buckets']['Bucket']['Name'])) {
            $this->Buckets = [new Bucket($data['Buckets']['Bucket'])];
        }
        else {
            $this->Buckets = [];
            foreach ($data['Buckets']['Bucket'] as $bucket) {
                array_push($this->Buckets, new Bucket($bucket));
            }
        }
    }
}